#include "collectpictureupper.h"

QMutex upper_frame_mutex;
QMutex cap_mutex;
Mat upper_frame;

extern VideoCapture cap;
extern bool cap_flag;

collectPictureUpper::collectPictureUpper(QObject *parent):QThread(parent)
{
}

void collectPictureUpper::run()
{
    Mat frame;
    while(true){
        if(cap_flag){
            cap_mutex.lock();
            cap.read(upper_frame);
            cap_mutex.unlock();

            upper_frame_mutex.lock();
            upper_frame.copyTo(frame);
            emit isready(&frame);
            upper_frame_mutex.unlock();
        }else{
            msleep(10);
        }
    }
}

